from google.appengine.ext import db

class Account(db.Model):
	accountID = db.IntegerProperty()
	name = db.StringProperty()
	subscriber = db.StringProperty()
	accountType = db.StringProperty()
	# contacts = db.ListProperty(db.ReferenceProperty(Contact))

class Contact(db.Model):
	contactID = db.IntegerProperty()
	firstName = db.StringProperty()
	lastName = db.StringProperty()
	address = db.ReferenceProperty(Address)
	emailAddress = db.EmailProperty()
	phoneNumber = db.PhoneNumberProperty()
	url = db.StringProperty()
	account = db.ReferenceProperty(Account)

class Address(db.Model):
	addressID = db.IntegerProperty()
	type = db.StringProperty()
	streetAddress = db.StringProperty()
	city = db.StringProperty()
	state = db.StringProperty()
	zipcode = db.StringProperty()
	country = db.StringProperty()

class Sequence(db.Model):
	name = db.StringProperty()
	nextNumber = db.IntegerProperty()

class Case(db.Model):
	caseNumber = db.IntegerProperty()
	summary = db.StringProperty()
	openedTS = db.DateTimeProperty()
	closedTS = db.DateTimeProperty()
	openedBy = db.StringProperty()
	owner = db.StringProperty()
	status = db.StringProperty()
	origin = db.StringProperty()
	reason = db.StringProperty()
	type = db.StringProperty()
	priority = db.StringProperty()
	subject = db.StringProperty()
	contact = db.ReferenceProperty(Contact)
	# attachments,comments
	
	# account = db.ReferenceProperty(Account)
	# notes = db.ListProperty(db.ReferenceProperty(Note))
	# events = db.ListProperty(db.ReferenceProperty(Event))
	# tasks = db.ListProperty(db.ReferenceProperty(Task))
	# attachments = db.ListProperty(db.ReferenceProperty(Attachment))
	
class Note(db.Model):
	note = db.TextProperty()
	createdTS = db.DateTimeProperty()
	creator = db.StringProperty()
	case = db.ReferenceProperty(Case)
	
	
class Event(db.Model):
	asignee = db.StringProperty()
	subject = db.StringProperty()
	case = db.ReferenceProperty(Case)
	contact = db.ReferenceProperty(Contact)
	allDayInd = db.BooleanProperty()
	startDateTime = db.DateTimeProperty()
	stopDateTime = db.DateTimeProperty()
	location = db.StringProperty()
	showTimeAs = db.StringProperty()
	description = db.StringProperty()
	recurringInd = db.BooleanProperty()
	frequency = db.StringProperty()
	everyNDaysInd = db.StringProperty()
	startDate = db.DateProperty()
	endDate = db.DateProperty()
	reminderInd = db.BooleanProperty()
	reminderType = db.StringProperty()
	
class Task(Event):
	status = db.StringProperty()
	priority = db.StringProperty()
	dueDate = db.DateProperty()
	
class Attachment(db.Model):
	fileName = db.StringProperty()
	content = db.BlobProperty()
	mimeType = db.StringProperty()
	# case = db.ReferenceProperty(Case)
	
		
__all__ = ["Account", "Contact", "Attachment", "Task", "Event", "Note", "Case", "Sequence"]